package com.xique.park.controller.auto;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xique.common.log.annotation.Log;
import com.xique.common.log.enums.BusinessType;
import com.xique.common.security.annotation.PreAuthorize;
import com.xique.park.bean.domain.ParkPlatePostpone;
import com.xique.park.service.service.IParkPlatePostponeService;
import com.xique.common.core.web.controller.BaseController;
import com.xique.common.core.web.domain.AjaxResult;
import com.xique.common.core.utils.poi.ExcelUtil;
import com.xique.common.core.web.page.TableDataInfo;

/**
 * 车辆续费Controller
 * 
 * @author xique
 * @date 2021-12-09
 */
@RestController
@RequestMapping("/postpone")
public class ParkPlatePostponeController extends BaseController
{
    @Autowired
    private IParkPlatePostponeService parkPlatePostponeService;

    /**
     * 查询车辆续费列表
     */
    @PreAuthorize(hasPermi = "park:postpone:list")
    @GetMapping("/list")
    public TableDataInfo list(ParkPlatePostpone parkPlatePostpone)
    {
        startPage();
        List<ParkPlatePostpone> list = parkPlatePostponeService.selectParkPlatePostponeList(parkPlatePostpone);
        return getDataTable(list);
    }

    /**
     * 导出车辆续费列表
     */
    @PreAuthorize(hasPermi = "park:postpone:export")
    @Log(title = "车辆续费", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ParkPlatePostpone parkPlatePostpone) throws IOException
    {
        List<ParkPlatePostpone> list = parkPlatePostponeService.selectParkPlatePostponeList(parkPlatePostpone);
        ExcelUtil<ParkPlatePostpone> util = new ExcelUtil<ParkPlatePostpone>(ParkPlatePostpone.class);
        util.exportExcel(response, list, "车辆续费数据");
    }

    /**
     * 获取车辆续费详细信息
     */
    @PreAuthorize(hasPermi = "park:postpone:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(parkPlatePostponeService.selectParkPlatePostponeById(id));
    }

    /**
     * 新增车辆续费
     */
    @PreAuthorize(hasPermi = "park:postpone:add")
    @Log(title = "车辆续费", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ParkPlatePostpone parkPlatePostpone)
    {
        return toAjax(parkPlatePostponeService.insertParkPlatePostpone(parkPlatePostpone));
    }

    /**
     * 修改车辆续费
     */
    @PreAuthorize(hasPermi = "park:postpone:edit")
    @Log(title = "车辆续费", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ParkPlatePostpone parkPlatePostpone)
    {
        return toAjax(parkPlatePostponeService.updateParkPlatePostpone(parkPlatePostpone));
    }

    /**
     * 删除车辆续费
     */
    @PreAuthorize(hasPermi = "park:postpone:remove")
    @Log(title = "车辆续费", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(parkPlatePostponeService.deleteParkPlatePostponeByIds(ids));
    }
}
